import request from '@/utils/request'

export default {
  getFoodbusinessList(searchModel) {
    let params = '&pageNo=' + searchModel.pageNo + '&pageSize=' + searchModel.pageSize
    params =
      searchModel.name === '' ||
      searchModel.name === null ||
      searchModel.name === undefined
        ? params
        : params + '&name=' + searchModel.name
    return request({
      url: '/foodbusiness/list?' + params,
      method: 'get'

      // params:{
      //   pageNo:searchModel.pageNo,
      //   pageSize:searchModel.pageSize,
      //   name:searchModel.name,
      // }
    })
  },
  addFoodbusiness(foodbusiness) {
    return request({
      url: '/foodbusiness/addFoodbusiness',
      method: 'post',
      data: foodbusiness
    })
  },
  updateFoodbusiness(foodbusiness) {
    return request({
      url: '/foodbusiness/updateFoodbusiness',
      // method: 'put',
      method: 'post',
      data: foodbusiness
    })
  },
  saveFoodbusiness(foodbusiness) {
    if (foodbusiness.foodbusinessId == null || foodbusiness.foodbusinessId === undefined) {
      return this.addFoodbusiness(foodbusiness)
    }
    return this.updateFoodbusiness(foodbusiness)
  },
  getFoodbusinessById(foodbusinessId) {
    return request({
      // url: '/foodbusiness/'+id,
      url: `/foodbusiness/getFoodbusinessById/${foodbusinessId}`,
      method: 'get'
    })
  },
  deleteById(foodbusinessId) {
    return request({
      url: `/foodbusiness/deleteFoodbusinessById`,
      method: 'delete',
      params: {
        deleteFoodbusinessId: foodbusinessId
      }
    })
  }

}
